<template>
	<el-descriptions ref="ruleFormRef" :column="2" direction="vertical" v-loading="isLoading">

		<!-- <el-descriptions-item width="50%" :label='titles.id'>
			{{ isNullOrEmpty( formInline?.id ) }}
		</el-descriptions-item>
		<el-descriptions-item width="50%" :label='titles.projectId'>
			{{ isNullOrEmpty( formInline?.projectId ) }}
		</el-descriptions-item> -->
		<el-descriptions-item width="50%" :label='titles.projectName'>
			{{ isNullOrEmpty( formInline.projectName ) }}
		</el-descriptions-item>
		<el-descriptions-item width="50%" :label='titles.unityName'>
			{{ isNullOrEmpty( formInline?.unityName ) }}
		</el-descriptions-item>
		<el-descriptions-item width="50%" :label='titles.mainteName'>
			{{ isNullOrEmpty( formInline?.mainteName ) }}
		</el-descriptions-item>
		<el-descriptions-item width="50%" :label='titles.contractNO'>
			{{ isNullOrEmpty( formInline?.contractNO ) }}
		</el-descriptions-item>
		<el-descriptions-item width="50%" :label='titles.unityAddress'>
			{{ isNullOrEmpty( formInline?.unityAddress ) }}
		</el-descriptions-item>
		<el-descriptions-item width="50%" :label='titles.beginDate'>
			{{ isNullOrEmpty( formInline?.beginDate ) }}
		</el-descriptions-item>
		<el-descriptions-item width="50%" :label='titles.endDate'>
			{{ isNullOrEmpty( formInline?.endDate ) }}
		</el-descriptions-item>
		<el-descriptions-item width="50%" :label='titles.status'>
			<el-tag v-if="formInline?.status == 1" type="success">履约中</el-tag>
			<el-tag v-if="formInline?.status == 2" type="warning">已过期</el-tag>
			<el-tag v-if="formInline?.status == 3" type="info">已失效</el-tag>
			<!-- {{ isNullOrEmpty( formInline?.status == 1 ? '履约中' : formInline?.status == 2 ? '已过期' : '已失效' ) }} -->
		</el-descriptions-item>

		<el-descriptions-item width="50%" :label='titles.circle'>
			{{ isNullOrEmpty( formInline?.circle ) }}
		</el-descriptions-item>

		 </el-descriptions>
		 <el-descriptions ref="ruleFormRef" :column="2" direction="vertical" >
			<el-descriptions-item width="100%" :label='titles.annex'>
			<!-- <UploadFile v-model:files='formInline.annexFiles' :addORupdate="2" :limit="100"  accept='.pdf,.docx,.png'
				:disabled="true"></UploadFile> -->
				<sj-link custom-type="sblue" :underline="false" style="display: block;" v-for="(item,index) in formInline.annexFiles"
				@click="lookList(item,index)">
				<div>{{ item.name }}</div>
			</sj-link>
			 <!-- <div class="cursor-pointer" v-for="(item,index) in formInline.annexFiles" >
				{{ item.name }}
			 </div> -->
		</el-descriptions-item>
		 </el-descriptions>
</template>

<script setup lang="ts">
import { isNullOrEmpty } from '@/utils/functions'
import { ref } from "vue";
import { titles } from './index';
import { cloneDeep, storageLocal } from "@pureadmin/utils";
import { formatToken, getToken, userKey } from "@/utils/auth";
import { message } from "@/utils/message";
import UploadFile from '@/components/ReUpload/maintenanceUpload.vue'
import type { infoType } from '@/api/operate/maintenance/contract/index';
import { usePageVariablesStoreHook, } from '@/store/modules/pageVariables'


const operate = usePageVariablesStoreHook().getOperate()
type FormProps = {
	formInline: infoType,
	isLoading: boolean
}

const props = withDefaults(defineProps<FormProps>(), {
	formInline: () => ({} as infoType),
	isLoading: false
});

const ruleFormRef = ref();

function handlePreview(file) {

	console.log("file", file);

};

const lookList = (item, index) => {

	if (storageLocal().getItem(userKey)?.userInfo?.roles?.operate?.includes('business.mainte.preview')) {
      window.open(item.url, '_blank')
    } else {
      message("无查看合同权限", {
        type: "warning"
      });
    }
}
function getRef() {
	return ruleFormRef.value;
}

defineExpose({ getRef });
</script>
